package net.kazed.nextaction.menu;

import java.util.Iterator;
import java.util.List;

import android.view.MenuItem;

public class OptionMenu {

   private List<OptionMenuItem> menuItems;
   
   public void add(OptionMenuItem menuItem) {
      menuItems.add(menuItem);
   }

   public boolean onOptionsItemSelected(MenuItem item) {
      boolean handled = false;
      for (Iterator<OptionMenuItem> itemIterator = menuItems.iterator(); !handled && itemIterator.hasNext();) {
         OptionMenuItem optionMenuItem = itemIterator.next();
         if (optionMenuItem.isMenu(item.getItemId())) {
            optionMenuItem.onSelected();
            handled = true;
         }
      }
      return handled ;
   }
}
